/**
 * Created by wry on 2015/1/23.
 */
var toolUtil = require('../common/utils/toolUtil');
var messageUtil = require('../common/utils/messageUtil');

exports.md5Validate = function (req, res, next) {

    if (enbaleMd5 == 'Yes' && req.method == 'POST') {
        if (Number(req.query.vcode) >= 200000) {
            var tempArray = req.url.split('/');
            var deviceId = tempArray[tempArray.length - 1].split('?')[0];

            var input = req.body;
            if (input == null) {
                next();
            } else {
                var result = toolUtil.md5Validate(deviceId, input);
                if (result) {
                    next();
                } else {
                    res.status(401).end()
                }
            }
        } else {
            next();
        }
    } else {
        next();
    }
};